﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Init {
    import flash.events.*;
    import Engine.Managers.*;
    import Engine.Init.*;
    import Classes.*;
    import flash.net.*;
    import Engine.*;

    public class BootstrapInit extends InitializationAction {

        public static const INIT_ID:String = "BootstrapInit";

        private var m_settingsUrl:String;
        private var m_rawXml:XML;

        public function BootstrapInit(_arg1:String){
            super(INIT_ID);
            this.m_settingsUrl = _arg1;
        }
        public function get setting():XML{
            return (this.m_rawXml);
        }
        override public function execute():void{
            var _local1:URLLoader = new URLLoader(new URLRequest(this.m_settingsUrl));
            _local1.dataFormat = URLLoaderDataFormat.BINARY;
            _local1.addEventListener(Event.COMPLETE, this.onConfigXmlLoaded);
            Global.bootstrap = this;
        }
        private function onConfigXmlLoaded(_arg1:Event):void{
            var raw:* = null;
            var assetUrl:* = null;
            var event:* = _arg1;
            try {
                raw = Utilities.uncompress(event.target.data);
            } catch(error:Error) {
                raw = event.target.data;
            };
            var xml:* = XML(raw);
            this.m_rawXml = xml;
            if (AssetUrlManager.initialized == false){
                if (((this.m_rawXml.assetIndex) && ((this.m_rawXml.assetIndex.length() > 0)))){
                    assetUrl = GlobalEngine.getFlashVar("asset_url").toString();
                    new AssetUrlManager(assetUrl, (assetUrl + this.m_rawXml.assetIndex.@hashedPrefix), this.m_rawXml.assetIndex.toString(), this.m_rawXml.assetPackIndex.toString());
                } else {
                    new AssetUrlManager(null, null, null, null);
                };
                AssetUrlManager.instance.setAssetDomains(2);
            };
            dispatchEvent(new Event(Event.COMPLETE));
        }

    }
}//package Init 
